<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>设置Frame</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
    .option {
        position: relative;
        box-sizing: border-box;
        height: 61px;
        border-bottom: 1px solid #ddd;
    }
    
    .option .title {
        position: relative;
        width: 100%;
        height: 60px;
        box-sizing: border-box;
        padding-left: 16px;
        line-height: 60px;
        font-size: 14px;
        color: #444;
        text-align: left;
    }
    
    .option .arrow-panel {
        position: absolute;
        top: 0;
        right: 12px;
        width: auto;
        height: 60px;
        background-image: url(../image/arrow_right.png);
        background-repeat: no-repeat;
        background-size: 16px 24px;
        background-position: right center;
    }
    
    .option .arrow-panel .text {
        box-sizing: border-box;
        width: auto;
        height: 60px;
        padding-right: 20px;
        line-height: 60px;
        font-size: 13px;
        color: #888;
        text-align: left;
    }
    
    .button {
        width: auto;
        height: 50px;
        margin-left: 32px;
        margin-right: 32px;
        margin-top: 16px;
        background-color: #f00;
        line-height: 50px;
        color: #fff;
        font-size: 20px;
        text-align: center;
        border-radius: 8px;
    }
    
    .highlight {
        opacity: 0.7;
    }
    </style>
</head>

<body>
    <section>
        <div class="option" tapmode onclick="fnClearCache();">
            <div class="title">清除缓存</div>
            <div class="arrow-panel">
                <div id="cacheSize" class="text"></div>
            </div>
        </div>
        <div class="option" tapmode onclick="fnOpenAboutWin();">
            <div class="title">关于</div>
            <div class="arrow-panel">
                <div class="text"></div>
            </div>
        </div>
        <div class="button" tapmode onclick="fnLogout();">退出登录</div>
    </section>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
apiready = function() {
    getCacheSize();
};

function getCacheSize() {
    api.getCacheSize(function(ret) {
        var size = ret.size;
        var cacheSize = $api.byId('cacheSize');
        size = parseInt((size / 1024 / 1024) * 100) / 100;
        cacheSize.innerHTML = size + ' M';
    });
}

function fnClearCache() {
    api.clearCache(function() {
        api.toast({
            msg: '缓存清除完毕'
        });
        setTimeout(function() {
            getCacheSize();
        }, 300);
    });
}

function fnOpenAboutWin () {
    api.openWin({
        name: 'about',
        url: './about.html'
    });
}

function fnLogout() {
    api.confirm({
        title: '提示',
        msg: '是否退出登录',
        buttons: ['确定', '取消']
    }, function(ret, err) {
        if (ret) {
            if (1 == ret.buttonIndex) {
                $api.rmStorage('userInfo');
                api.closeToWin({
                    name: 'main'
                });
            }
        }
    });
}
</script>

</html>
